<template>
  <div class="main-page">
<el-form class="dialog-form" :rules="rules"  ref="dataForm" style="width:500px" :model="temp" label-position="left" label-width="120px">
        
        <el-form-item label="所属分类" prop="categoryId">          
                <el-cascader
                  placeholder="选择所属分类"
                  :options="parentCategories"
                  v-model="temp.categoryId"
                  filterable
                  change-on-select
                ></el-cascader>
        </el-form-item>         
        
        <el-form-item label="商品类型" prop="typeId">          
            
                
                  <el-select v-model="temp.typeId" placeholder="请选择">
                    <el-option
                      v-for="item in typeIdOptions"
                      :key="item.value"
                      :label="item.text"
                      :value="item.value">
                    </el-option>
                  </el-select>
                
            
        </el-form-item>         
        
        <el-form-item label="商品名称" prop="title">          
            
                                  
                  <el-input v-model="temp.title" placeholder=""></el-input>
                
            
        </el-form-item>         
        
        <el-form-item label="商品简介" prop="intro">          
            
                                  
                  <el-input v-model="temp.intro" placeholder=""></el-input>
                
            
        </el-form-item>         
        
        <el-form-item label="商家编码" prop="shopNo">          
            
                  <el-input v-model="temp.shopNo" placeholder=""></el-input>
                
            
        </el-form-item>         
        
        <el-form-item label="计量单位" prop="goodsUnit">          
            
                                  
                  <el-input v-model="temp.goodsUnit" placeholder="输入中文或英文,例如 g/元"></el-input>
                
            
        </el-form-item>         
        
        <el-form-item label="商品标签定义" prop="tagIds">          
            
                                  
                  <el-input v-model="temp.tagIds" placeholder=""></el-input>
                
            
        </el-form-item>         
        
        <el-form-item label="销售状态" prop="status">          
            
                                  
                  <el-input v-model="temp.status" placeholder=""></el-input>
                
            
        </el-form-item>         
        
        <el-form-item label="运费模板" prop="freightTemplateId">          
            
                                  
                  <el-input v-model="temp.freightTemplateId" placeholder=""></el-input>
                
            
        </el-form-item>         
        
        <el-form-item label="市场价" prop="marketPrice">          
            
                                  
                  <el-input v-model="temp.marketPrice" placeholder=""></el-input>
                
            
        </el-form-item>         
        
        <el-form-item label="一口价" prop="price">          
            
                                  
                  <el-input v-model="temp.price" placeholder=""></el-input>
                
            
        </el-form-item>         
        
        <el-form-item label="成本价" prop="costPrice">          
            
                                  
                  <el-input v-model="temp.costPrice" placeholder=""></el-input>
                
            
        </el-form-item>         
        
        <el-form-item label="货号" prop="goodsNo">          
            
                                  
                  <el-input v-model="temp.goodsNo" placeholder=""></el-input>
                
            
        </el-form-item>         
        
        <el-form-item label="商品库存" prop="stock">          
            
                                  
                  <el-input v-model="temp.stock" placeholder=""></el-input>
                
            
        </el-form-item>         
        
        <el-form-item label="警戒库存" prop="alertStock">          
            
                                  
                  <el-input v-model="temp.alertStock" placeholder=""></el-input>
                
            
        </el-form-item>         
        
        <el-form-item label="内容编辑" prop="content">          
            
                                  
                  <el-input v-model="temp.content" placeholder=""></el-input>
                
            
        </el-form-item>         
                         
      </el-form>
      <div class="dialog-footer">
        <el-button type="primary" :loading="submiting" @click="submitFormAction">确定</el-button>
      </div>
  </div>
  
</template>

<script>


export default {
  
  data() {
    return {
      temp: {
        id: "",
        categoryId: "",
        typeId: "",
        title: "",
        intro: "",
        shopNo: "",
        goodsUnit: "",
        tagIds: "",
        status: "",
        freightTemplateId: "",
        marketPrice: "",
        price: "",
        costPrice: "",
        goodsNo: "",
        stock: "",
        alertStock: "",
        content: ""
      },

      parentCategories:[],
      typeIdOptions: [],

      rules: {
        categoryId: [
          { required: true, message: "所属分类不能为空", trigger: "change" }
        ],

        typeId: [
          { required: true, message: "商品类型不能为空", trigger: "change" }
        ],

        title: [
          {
            required: true,
            message: "商品名称不能为空",
            trigger: "change",
            max: 60
          }
        ],

        intro: [
          {
            required: true,
            message: "商品简介不能为空",
            trigger: "change",
            max: 900
          }
        ],

        shopNo: [
          {
            required: true,
            message: "商家编码不能为空",
            trigger: "change",
            max: 60
          }
        ],

        goodsUnit: [
          {
            required: true,
            message: "计量单位不能为空",
            trigger: "change",
            max: 60
          }
        ],

        tagIds: [
          {
            required: true,
            message: "商品标签定义不能为空",
            trigger: "change",
            max: 600
          }
        ],

        status: [
          { required: true, message: "销售状态不能为空", trigger: "change" }
        ],

        freightTemplateId: [
          { required: true, message: "运费模板不能为空", trigger: "change" }
        ],

        marketPrice: [
          { required: true, message: "市场价不能为空", trigger: "change" }
        ],

        price: [
          { required: true, message: "一口价不能为空", trigger: "change" }
        ],

        costPrice: [
          { required: true, message: "成本价不能为空", trigger: "change" }
        ],

        goodsNo: [
          {
            required: true,
            message: "货号不能为空",
            trigger: "change",
            max: 60
          }
        ],

        stock: [
          { required: true, message: "商品库存不能为空", trigger: "change" }
        ],

        alertStock: [
          { required: true, message: "警戒库存不能为空", trigger: "change" }
        ],

        content: [
          { required: true, message: "内容编辑不能为空", trigger: "change" }
        ]
      }
    };
  },
  created() {
    this.init("goods", 1).loadData();
    this.combOptions("goods_type").then(info => {
      this.typeIdOptions = info;
    });
    this.$query("/admin/goods_category/tree").then(info => {
          this.parentCategories = [
          ];
          this.parentCategories.push(...info);
        });
  },
  filters: {},
  methods: {
    
  }
};
</script>
<style>
.dialog-footer{
  width: 500px;
  text-align:right;
  padding-right:50px;
}

</style>


